{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
}}

<Hds::AppFrame @hasSidebar={{@showSidebar}} @hasHeader={{false}} @hasFooter={{false}} as |Frame|>
  <Frame.Sidebar data-test-sidebar-nav>
    <Hds::SideNav @isResponsive={{true}} @hasA11yRefocus={{true}} @a11yRefocusSkipTo="app-main-content">
      <:header>
        <Hds::SideNav::Header>
          <:logo>
            <Hds::SideNav::Header::HomeLink
              @icon="vault"
              @route="vault.cluster.dashboard"
              @model={{this.currentCluster.cluster.name}}
              @ariaLabel="Vault home"
              data-test-sidebar-logo
            />
          </:logo>
          <:actions>
            <Hds::Button
              @isIconOnly={{true}}
              @size="large"
              @icon="terminal-screen"
              @text="Console toggle"
              data-test-console-toggle
              {{on "click" (fn (mut this.console.isOpen) (not this.console.isOpen))}}
              {{on "click" this.trackReplToggle}}
            />
            <Sidebar::UserMenu />
          </:actions>
        </Hds::SideNav::Header>
      </:header>

      {{! this block is where the Hds::SideNav::Portal components render into }}
      <:body>
        <Hds::SideNav::Portal::Target />
      </:body>

      <:footer>
        {{#if (has-feature "Namespaces")}}
          <NamespacePicker class="hds-side-nav-hide-when-minimized" />
        {{/if}}
      </:footer>
    </Hds::SideNav>
  </Frame.Sidebar>
  <Frame.Main id="app-main-content" class={{if this.console.isOpen "main--console-open"}}>
    {{! outlet for app content }}
    <LinkStatus @status={{this.currentCluster.cluster.hcpLinkStatus}} />
    {{yield}}
    <div data-test-console-panel class={{if this.console.isOpen "panel-open"}}>
      {{#if this.console.isOpen}}
        <Console::UiPanel
          @isFullscreen={{this.consoleFullscreen}}
          {{focus-trap
            focusTrapOptions=(hash initialFocus="#console-input" clickOutsideDeactivates=true onDeactivate=this.closeConsole)
          }}
        />
      {{/if}}
    </div>
  </Frame.Main>
</Hds::AppFrame>